package com.ebeijia.myenum;

import org.apache.commons.lang3.StringUtils;

/**
 * Created by YPJ on 2016/5/18.
 */
public enum NoticeInfoTypeEnum {
    water_off("01", "停水通知"),
    wq("02", "水质公告"),
    k_Pa("03", "水压公告"),
    company("04","企业动态"),
    pay_corr("05","缴费标准");

    private String code;
    private String text;

    private NoticeInfoTypeEnum(String code, String text) {
        this.code = code;
        this.text = text;
    }

    public String getCode() {
        return code;
    }

    public String getText() {
        return text;
    }

    public static String text(String code) {
        if (StringUtils.isBlank(code)) {
            return StringUtils.EMPTY;
        }

        for (NoticeInfoTypeEnum state : NoticeInfoTypeEnum.values()) {
            if (StringUtils.equals(state.getCode(), code)) {
                return state.getText();
            }
        }

        return StringUtils.EMPTY;
    }

    public static ApplyWaterSteteEnum of(String code) {
        for (ApplyWaterSteteEnum state : ApplyWaterSteteEnum.values()) {
            if (StringUtils.equals(state.getCode(), code)) {
                return state;
            }
        }
        return null;
    }

}
